Amber's Digital Garden

Unreal Custom log Categories

How to define custom log categories in Unreal C++


Place this in a header file and include it to reuse a log category between multiple source files Arguments:

  1. Name of your custom category. You can use LogTemp if you don't want to define a category.
  2. Default verbosity when one is not specified. The most common value is Log. Valid verbosity levels are: Fatal, Error, Warning, Display, Log, Verbose, VeryVerbose
  3. Maximum verbosity level to allow when compiling. Can also be All
DECLARE_LOG_CATEGORY_EXTERN(MyLogCategory, Log, All);

Place this in your log definition's .cpp file to define it

DEFINE_LOG_CATEGORY(MyLogCategory);

Place this on your code when you want to log something Arguments:

  1. Log category
  2. Log verbosity level. Will determine display and some behavior
  3. Message to log. Uses a TCHAR array, therefore the TEXT wrapper
UE_LOG(MyLogCategory, Log, TEXT("Your log message goes here."));

You can also use sprintf()-like string formatting to log variables:

int32 MyValue = 10;
UE_LOG(MyLogCategory, Log, TEXT("Your variable value is: %d"), MyValue);

Sources:


by amber